<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true">
      <el-form-item label="">
        <el-select v-model="queryParams.railwayName" placeholder="线名" clearable style="width: 140px">
          <el-option v-for="dict in railwayNameobj" :key="dict.railwayName" :label="dict.railwayName" :value="dict.id" />
        </el-select>
      </el-form-item>
      <el-form-item label="" class="formitemcla">
        <el-input v-model="queryParams.startingMileage" placeholder="起点里程" clearable style="width: 140px">
          <template #suffix> km </template>
        </el-input>
      </el-form-item>
      <el-form-item label="~">
        <el-input v-model="queryParams.destinationMileage" placeholder="终点里程" clearable style="width: 140px">
          <template #suffix> km </template>
        </el-input>
      </el-form-item>
      <el-form-item label="">
        <el-input v-model="queryParams.tunnelCode" placeholder="隧道号" clearable style="width: 150px"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getList" style="width: 90px">查询</el-button>
        <el-button @click="resetQuery" style="width: 90px">重置</el-button>
        <el-button type="primary" @click="handleQuery" style="width: 90px">导出</el-button>
        <el-button type="primary" @click="handleAdd" style="width: 90px">新增</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="railList" height="63vh" border @selection-change="selectiontab">
      <el-table-column type="selection" label="全选" width="85" />
      <el-table-column label="序号" type="index" width="80" />
      <el-table-column label="隧道名称" prop="tunnelName" min-width="80" />
      <el-table-column label="中心里程" prop="centreMileageStr" min-width="80" />
      <el-table-column label="起止里程" prop="startingMileageStr" min-width="200">
        <template #default="scope">
          <span>{{ scope.row.startingMileageStr + "~" +  scope.row.destinationMileageStr}}</span>
        </template>
      </el-table-column>
      <el-table-column label="上下行" prop="lineType" min-width="80" />
      <el-table-column label="延长米" prop="lengthen" min-width="80" />
      <el-table-column label="坡度(‰)" prop="slope" min-width="80" />
      <el-table-column label="曲线半径(m)" prop="curveRadius" min-width="80" />
      <el-table-column label="建成年限" prop="completionPeriod" min-width="80" />
      <el-table-column label="衬砌类型" prop="liningType" min-width="80" />
      <el-table-column label="隧道边墙类型" prop="flankWallType" min-width="80" />
      <el-table-column label="仰拱情况" prop="inflectedArch" min-width="80" />
      <el-table-column label="病害整治情况" prop="diseaseControlSituation" min-width="80" />
      <el-table-column label="病害整治年份" prop="yearOfDiseaseControl" min-width="80" />
      <el-table-column label="隧道类型" prop="length" min-width="80" />
      <el-table-column label="照明情况" prop="lightingFacility" min-width="80" />
      <el-table-column label="备注" prop="comment" min-width="80" />
      <el-table-column label="直接数据" min-width="100">
        <template #default="scope">
          <div class="buttontext">
            <el-button link type="primary" @click="parameter(scope.row)">参数</el-button>
            <el-button link type="primary" @click="meansFun(scope.row)">资料</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="关联数据" min-width="200">
        <template #default="scope">
          <div class="buttontext">
            <el-button link type="primary" @click="resumeUpdate(scope.row)">作业履历</el-button>
            <el-button link type="primary" @click="deviceProblem(scope.row)">设备问题</el-button>
            <el-button link type="primary" @click="businessFinance(scope.row)">业财</el-button>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="100">
        <template #default="scope">
          <div class="buttontext">
            <el-button link type="primary" @click="handDelete(scope.row.id)">删除</el-button>
          </div>
        </template>
      </el-table-column>
    </el-table>
    <!-- 添加或修改用户配置对话框 -->
    <el-dialog :title="title" v-model="open" width="1300px" append-to-body>
      <el-form ref="userRef" :model="form" :rules="rules" label-width="80px" :inline="true">
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">位置</span>
          <span class="rightx"></span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="单位名称" prop="unitId">
              <el-select filterable clearable style="width: 180px" v-model="form.unitId" placeholder="请选择">
                <el-option v-for="dict in unitNameobj" :key="dict.id" :label="dict.unitName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="线名" prop="railwayId">
              <el-select filterable clearable style="width: 180px" v-model="form.railwayId" placeholder="请选择" @change="updateproperyfun()">
                <el-option v-for="dict in railwayNameobj" :key="dict.id" :label="dict.railwayName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="上下行" prop="lineTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.lineTypeId" placeholder="请选择" @change="updateproperyfun()">
                <el-option v-for="dict in progressTypeobj" :key="dict.id" :label="dict.progressType" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="中心里程" prop="centreMileage">
              <el-input type="number" v-model="form.centreMileage" placeholder="请输入中心里程" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="." prop="startingMileage">
              <el-input type="number" @blur="updateproperyfun()" v-model="form.startingMileage" placeholder="请输入起点里程" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="终点里程" prop="destinationMileage">
              <el-input type="number" @blur="updateproperyfun()" v-model="form.destinationMileage" placeholder="请输入终点里程" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="隧道位置补充描述" prop="tunnelLocationDescription">
              <el-input v-model="form.tunnelLocationDescription" placeholder="请输入隧道位置补充描述" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隧道号" prop="tunnelCode">
              <el-input v-model="form.tunnelCode" placeholder="请输入隧道号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隧道名" prop="tunnelName">
              <el-input v-model="form.tunnelName" placeholder="请输入隧道名" />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">特性</span>
          <span class="rightx"></span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="延长米" prop="lengthen">
              <el-input v-model="form.lengthen" placeholder="请输入延长米" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="建成年限" prop="completionPeriod">
              <el-date-picker
                style="width: 180px"
                format="YYYY/MM/DD"
                value-format="YYYY/MM/DD"
                v-model="form.completionPeriod"
                type="datetime"
                placeholder="请选择开工日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="仰拱情况" prop="inflectedArch">
              <el-input v-model="form.inflectedArch" placeholder="请输入仰拱情况" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="设计载荷" prop="designLoad">
              <el-input v-model="form.designLoad" placeholder="请输入设计载荷" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="管养单位" prop="nutritionUnit">
              <el-input v-model="form.nutritionUnit" placeholder="请输入管养单位" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所在路名" prop="placeName">
              <el-input v-model="form.placeName" placeholder="请输入所在路名" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="开工日期" prop="commencementDate">
              <el-date-picker
                style="width: 180px"
                format="YYYY/MM/DD"
                value-format="YYYY/MM/DD"
                v-model="form.commencementDate"
                type="datetime"
                placeholder="请选择竣工日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="竣工日期" prop="completedDate">
              <el-date-picker
                style="width: 180px"
                format="YYYY/MM/DD"
                value-format="YYYY/MM/DD"
                v-model="form.completedDate"
                type="datetime"
                placeholder="请选择竣工日期"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隧道长宽" prop="tunnelLength">
              <el-input type="number" v-model="form.tunnelLength" placeholder="请输入隧道长宽" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="隧道净宽" prop="tunnelClearWidth">
              <el-input v-model="form.tunnelClearWidth" placeholder="请输入隧道净宽" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="路面宽度" prop="tunnelWidth">
              <el-input type="number" v-model="form.tunnelWidth" placeholder="请输入路面宽度" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="净高" prop="clearHeight">
              <el-input type="number" v-model="form.clearHeight" placeholder="请输入净高" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="岩层地质" prop="stratum">
              <el-input v-model="form.stratum" placeholder="请输入岩层地质" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="困岩分类" prop="wallRockType">
              <el-input v-model="form.wallRockType" placeholder="请输入困岩分类" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="线路中心距" prop="railwayCenterDistance">
              <el-input v-model="form.railwayCenterDistance" placeholder="请输入线路中心距" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="避车洞数" prop="refugeHoleNum">
              <el-input-number precision="0" step="1" min="0" v-model="form.refugeHoleNum" placeholder="请输入避车洞数" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="巡看守方式" prop="warderId">
              <el-input v-model="form.warderId" placeholder="请输入巡看守方式" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="设计界限" prop="designLimit">
              <el-input v-model="form.designLimit" placeholder="请输入设计界限" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="轨道类型" prop="tunnelTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.tunnelTypeId" placeholder="请选择">
                <el-option v-for="dict in tunnelTypeIdList" :key="dict.id" :label="dict.propertyName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="洞门进口类型" prop="portalTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.portalTypeId" placeholder="请选择">
                <el-option v-for="dict in portalTypeIdList" :key="dict.id" :label="dict.propertyName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="洞口进口图号" prop="portalChartId">
              <el-input v-model="form.portalChartId" placeholder="请输入洞口进口图号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="衬砌图号" prop="liningChartId">
              <el-input v-model="form.liningChartId" placeholder="请输入衬砌图号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="防排水" prop="preventOutfall">
              <el-input v-model="form.preventOutfall" placeholder="请输入防排水" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隧道边墙类型" prop="flankWallTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.flankWallTypeId" placeholder="请选择">
                <el-option v-for="dict in flankWallTypeIdList" :key="dict.id" :label="dict.propertyName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="衬砌类型" prop="liningTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.liningTypeId" placeholder="请选择">
                <el-option v-for="dict in liningTypeIdList" :key="dict.id" :label="dict.propertyName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="明洞衬砌" prop="openCutTunnelLining">
              <el-input v-model="form.openCutTunnelLining" placeholder="请输入明洞衬砌" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="路面类型" prop="roadbedTypeId">
              <el-select filterable clearable style="width: 180px" v-model="form.roadbedTypeId" placeholder="请选择">
                <el-option v-for="dict in roadbedTypeIdList" :key="dict.id" :label="dict.propertyName" :value="dict.id"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="洞门形式" prop="portalShape">
              <el-input v-model="form.portalShape" placeholder="请输入洞门形式" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隧道洞门" prop="tunnelPortal">
              <el-input v-model="form.tunnelPortal" placeholder="请输入隧道洞门" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="明洞洞门" prop="openCutTunnelPortal">
              <el-input v-model="form.openCutTunnelPortal" placeholder="请输入明洞洞门" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="配供电设施" prop="powerSupply">
              <el-input v-model="form.powerSupply" placeholder="请输入配供电设施" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="照明情况" prop="lightingFacility">
              <el-input v-model="form.lightingFacility" placeholder="请输入照明情况" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通风设施" prop="ventilate">
              <el-input v-model="form.ventilate" placeholder="请输入通风设施" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="消防与救援设备" prop="fireRescue">
              <el-input v-model="form.fireRescue" placeholder="请输入消防与救援设备" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="监控设备" prop="monitoring">
              <el-input v-model="form.monitoring" placeholder="请输入监控设备" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="洞内纵坡" prop="cavityLongitudinalSlope">
              <el-input v-model="form.cavityLongitudinalSlope" placeholder="请输入洞内纵坡" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="按隧道内瓦斯浓度分类" prop="gasDensity">
              <el-input v-model="form.gasDensity" placeholder="请输入按隧道内瓦斯浓度分类" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="按道床结构分类" prop="roadBedStructure">
              <el-input v-model="form.roadBedStructure" placeholder="请输入按道床结构分类" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="按隧道跨度分类" prop="tunnelFlyPast">
              <el-input v-model="form.tunnelFlyPast" placeholder="请输入按隧道跨度分类" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="按围岩压力分类" prop="wallRockPressure">
              <el-input v-model="form.wallRockPressure" placeholder="请输入按围岩压力分类" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="按所在位置分类" prop="location">
              <el-input v-model="form.location" placeholder="请输入按所在位置分类" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="按隧道埋置深度分类" prop="tunnelDepth">
              <el-input v-model="form.tunnelDepth" placeholder="请输入按隧道埋置深度分类" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="隧道类型" prop="length">
              <el-input v-model="form.length" placeholder="请输入隧道类型" />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">相关特性</span>
          <span class="rightx"></span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="坡度(‰)" prop="slope">
              <el-input  v-model="form.slope" placeholder="请输入坡度(‰)" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="曲线半径(m)" prop="curveRadius">
              <el-input  v-model="form.curveRadius" placeholder="请输入曲线半径(m)" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="曲线长" prop="curveLength">
              <el-input  v-model="form.curveLength" placeholder="请输入曲线长" />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">健康值</span>
          <span class="rightx"></span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="健康值" prop="healthIndex">
              <el-input v-model="form.healthIndex" placeholder="请输入健康值" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="隐患等级" prop="hiddenDangerLevel">
              <el-input v-model="form.hiddenDangerLevel" placeholder="请输入隐患等级" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="存在问题" prop="existingProblem">
              <el-input v-model="form.existingProblem" placeholder="请输入存在问题" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="病害整治情况" prop="diseaseControlSituation">
              <el-input v-model="form.diseaseControlSituation" placeholder="请输入病害整治情况" /> </el-form-item
          ></el-col>
          <el-col :span="8">
            <el-form-item label="病害整治年份" prop="yearOfDiseaseControl">
              <el-input v-model="form.yearOfDiseaseControl" placeholder="请输入病害整治年份" /> </el-form-item
          ></el-col>
          <el-col :span="8">
            <el-form-item label="设备使用频率" prop="equipmentUsageFrequency">
              <el-input v-model="form.equipmentUsageFrequency" placeholder="请输入设备使用频率" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="设备综合效率(OEE)" prop="overallEquipmentEfficiency">
              <el-input v-model="form.overallEquipmentEfficiency" placeholder="请输入设备综合效率(OEE)" /> </el-form-item
          ></el-col>
          <el-col :span="8">
            <el-form-item label="平均无故障工作时间(MTTF)" prop="meanTimeToFailure">
              <el-input v-model="form.meanTimeToFailure" placeholder="请输入平均无故障工作时间(MTTF)" /> </el-form-item
          ></el-col>
          <el-col :span="8">
            <el-form-item label="平均修复时间(MTTR)" prop="meanTimeToRepair">
              <el-input v-model="form.meanTimeToRepair" placeholder="请输入平均修复时间(MTTR)" />
            </el-form-item>
          </el-col>
        </el-row>
        <div class="divflex">
          <span class="leftx"></span>
          <span class="mainz">管理</span>
          <span class="rightx"></span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="区段" prop="sector">
              <el-input v-model="form.sector" placeholder="请输入区段" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="工区" prop="workArea">
              <el-input v-model="form.workArea" placeholder="请输入工区" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="人员" prop="personnel">
              <el-input v-model="form.personnel" placeholder="请输入人员" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="包保责任人" prop="personInCharge">
              <el-input v-model="form.personInCharge" placeholder="请输入包保责任人" /> </el-form-item
          ></el-col>
          <el-col :span="8">
            <el-form-item label="备注" prop="comment">
              <el-input v-model="form.comment" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="divflex" v-if="parameterShow">
        <span class="leftx"></span>
        <span class="mainz">修改历史</span>
        <span class="rightx"></span>
      </div>
      <el-table :data="allBridgeChangeData" border height="300px" v-if="parameterShow">
        <el-table-column label="序号" type="index" width="80" />
        <el-table-column label="指标名" prop="property" min-width="80"></el-table-column>
        <el-table-column label="变更前指标值" prop="oldValue" min-width="80"></el-table-column>
        <el-table-column label="变更后指标值" prop="newValue" min-width="80"></el-table-column>
        <el-table-column label="变更时间" prop="createTime" min-width="80"></el-table-column>
        <el-table-column label="操作用户名" prop="user" min-width="80"></el-table-column>
      </el-table>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog draggable title="资料" v-model="meansopen" width="1300px" append-to-body @close="closefun">
      <means :form="formam" parentName="基本信息" v-if="meansopen"></means>
    </el-dialog>
  </div>
</template>

<script setup name="Bridge">
import means from "@/components/railmodle/means.vue";
import { useContent } from "@/mixin/index.js";
const { meansopen, meansFun, formam, closefun, resumeUpdate, deviceProblem, businessFinance } = useContent();
import {
  selectManTunnelOverviewList,
  addinsertManTunnelOverview,
  editManTunnelOverview,
  deleteManTunnelOverviewById,
  selectManTunnelOverviewById,
  getselectManTunnelEditRecordList,
  getSelectListApi,
  // selectManTunnelOverviewList,
} from "@/api/main/bridge.js";
import {
  selectManBasicUnitListapi,
  selectManBasicRailwayListapi,
  selectManBasicprogressTypeListapi,
  selectManRailFacilityCurveListapi,
  selectManRailFacilitySlopeListapi,
} from "@/api/main/api.js";
import { reactive, ref, toRefs } from "vue";
const { proxy } = getCurrentInstance();
const title = ref("新增");
const loading = ref(true);
const open = ref(false);
const equipmentproblemShow = ref(false);
const businessFinanceShow = ref(false);

const parameterShow = ref(false);

defineExpose({ getList });
const emit = defineEmits(["parentCount"]);

const data = reactive({
  faultForm: {
    railwayName: "",
    tabledata: [],
  },
  railList: [],
  selecttabList: [],
  //单位名称列表数据
  unitNameobj: [],
  //线名数据列表
  railwayNameobj: [],
  //行别数据列表
  progressTypeobj: [],
  // 轨道类型
  tunnelTypeIdList: [],
  // 洞门进口类型
  portalTypeIdList: [],
  // 隧道边墙类型
  flankWallTypeIdList: [],
  // 衬砌类型
  liningTypeIdList: [],
  // 路面类型
  roadbedTypeIdList: [],
  form: {},
  queryParams: {
    pageNum: "1",
    pageSize: "10",
    railwayName: "",
    startingMileage: "",
    destinationMileage: "",
    tunnelCode: "",
  },
  rules: {
    unitId: [{ required: true, message: "单位名称不能为空", trigger: ["blur", "change"] }],
    railwayId: [{ required: true, message: "线名不能为空", trigger: ["blur", "change"] }],
    lineTypeId: [{ required: true, message: "上下行不能为空", trigger: ["blur", "change"] }],
    tunnelCode: [{ required: true, message: "隧道号不能为空", trigger: ["blur", "change"] }],
    tunnelName: [{ required: true, message: "隧道名不能为空", trigger: ["blur", "change"] }],
    centreMileage: [{ required: true, message: "中心里程不能为空", trigger: ["blur", "change"] }],
    startingMileage: [{ required: true, message: "起点里程不能为空", trigger: ["blur", "change"] }],
    destinationMileage: [{ required: true, message: "终点里程不能为空", trigger: ["blur", "change"] }],
  },
  allBridgeChangeData: [],
  economyTableData: [],
  ledgerTabledata: [],
  stationList: [],
  slopeList: [],
});

const {
  slopeList,
  stationList,
  faultForm,
  queryParams,
  railList,
  selecttabList,
  form,
  rules,
  unitNameobj,
  railwayNameobj,
  progressTypeobj,
  bridgeList,
  tunnelCodeList,
  tunnelTypeIdList,
  flankWallTypeIdList,
  liningTypeIdList,
  roadbedTypeIdList,
  portalTypeIdList,
  allBridgeChangeData,
  economyTableData,
  ledgerTabledata,
} = toRefs(data);

const pageNumparent = ref(undefined);
const pageSizeparent = ref(undefined);

function init() {
  getLineDataList();
  getUnitDataList();
  getxbData();
  getgdlxData();
  getdkjklxData();
  getcqlxData();
  getlmlxData();
  getbqlxData();
  getList();
}
init();
/** 查询列表 */
function getList(pageNum, pageSize) {
  loading.value = true;
  if (pageNum != undefined || pageSize != undefined) {
    pageNumparent.value = pageNum;
    pageSizeparent.value = pageSize;
    queryParams.value.pageNum = pageNum == undefined ? 1 : pageNum;
    queryParams.value.pageSize = pageSize == undefined ? 10 : pageSize;
  } else {
    queryParams.value.pageNum = pageNumparent.value == undefined ? "1" : pageNumparent.value;
    queryParams.value.pageSize = pageSizeparent.value == undefined ? "10" : pageSizeparent.value;
  }
  selectManTunnelOverviewList({
    pageNum: queryParams.value.pageNum,
    pageSize: queryParams.value.pageSize,
    startingMileage: queryParams.value.startingMileage,
    destinationMileage: queryParams.value.destinationMileage,
    railwayId: queryParams.value.railwayName,
    tunnelCode: queryParams.value.tunnelCode,
  }).then((res) => {
    if (res.code == 200) {
      data.railList = res.data;
    }
    loading.value = false;
    emit("parentCount", res.count);
  });
}
/** 查询基础数据-线名数据列表 */
function getLineDataList() {
  selectManBasicRailwayListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      railwayNameobj.value = res.data;
      console.log(railwayNameobj.value);
    }
  });
}
/** 查询基础数据-单位数据列表 */
function getUnitDataList() {
  selectManBasicUnitListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      unitNameobj.value = res.data;
      console.log(unitNameobj.value);
    }
  });
}
/** 查询基础数据-行别数据列表 */
function getxbData() {
  selectManBasicprogressTypeListapi({ hasDelete: 0 }).then((res) => {
    if (res.code == 200) {
      progressTypeobj.value = res.data;
      console.log(progressTypeobj.value);
    }
  });
}

/** 查询-轨道类型数据列表 */
function getgdlxData() {
  getSelectListApi({ propertyType: "轨道类型" }).then((res) => {
    if (res.code == 200) {
      tunnelTypeIdList.value = res.data;
    }
  });
}
/** 查询-洞口进口类型数据列表 */
function getdkjklxData() {
  getSelectListApi({ propertyType: "洞门进口类型" }).then((res) => {
    if (res.code == 200) {
      portalTypeIdList.value = res.data;
    }
  });
}

/** 查询-隧道边墙类型数据列表 */
function getbqlxData() {
  getSelectListApi({ propertyType: "边墙类型" }).then((res) => {
    if (res.code == 200) {
      flankWallTypeIdList.value = res.data;
    }
  });
}

/** 查询-衬砌类型数据列表 */
function getcqlxData() {
  getSelectListApi({ propertyType: "衬砌类型" }).then((res) => {
    if (res.code == 200) {
      liningTypeIdList.value = res.data;
    }
  });
}

/** 查询-路面类型数据列表 */
function getlmlxData() {
  getSelectListApi({ propertyType: "路面类型" }).then((res) => {
    if (res.code == 200) {
      roadbedTypeIdList.value = res.data;
    }
  });
}

/* 删除单行数据 */
function handDelete(row) {
  deleteManTunnelOverviewById({ id: row }).then((res) => {
    if (res.code == 200) {
      proxy.$modal.msgSuccess("删除成功");
      getList();
    }
  });
}

/** 重置操作表单 */
function reset() {
  form.value = {
    id: "",
    unitId: "",
    railwayId: "",
    lineTypeId: "",
    centreMileage: "",
    startingMileage: "",
    destinationMileage: "",
    centreMileageSt: "",
    startingMileageStr: "",
    destinationMileageStr: "",
    tunnelLocationDescription: "",
    tunnelCode: "",
    tunnelName: "",
    lengthen: "",
    completionPeriod: "",
    inflectedArch: "",
    designLoad: "",
    nutritionUnit: "",
    placeName: "",
    commencementDate: "",
    completedDate: "",
    tunnelLength: "",
    tunnelClearWidth: "",
    tunnelWidth: "",
    clearHeight: "",
    stratum: "",
    wallRockType: "",
    railwayCenterDistance: "",
    refugeHoleNum: "",
    warderId: "",
    designLimit: "",
    tunnelTypeId: "",
    portalTypeId: "",
    portalChartId: "",
    liningChartId: "",
    preventOutfall: "",
    flankWallTypeId: "",
    liningTypeId: "",
    openCutTunnelLining: "",
    roadbedTypeId: "",
    portalShape: "",
    tunnelPortal: "",
    openCutTunnelPortal: "",
    powerSupply: "",
    lightingFacility: "",
    ventilate: "",
    fireRescue: "",
    monitoring: "",
    cavityLongitudinalSlope: "",
    gasDensity: "",
    roadBedStructure: "",
    tunnelFlyPast: "",
    wallRockPressure: "",
    location: "",
    tunnelDepth: "",
    length: "",
    slope: "",
    curveRadius: "",
    curveLength: "",
    healthIndex: "",
    hiddenDangerLevel: "",
    existingProblem: "",
    diseaseControlSituation: "",
    yearOfDiseaseControl: "",
    equipmentUsageFrequency: "",
    overallEquipmentEfficiency: "",
    meanTimeToFailure: "",
    meanTimeToRepair: "",
    sector: "",
    workArea: "",
    personnel: "",
    personInCharge: "",
    comment: "",
  };
  proxy.resetForm("userRef");
}
/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "新增";
  parameterShow.value = false;
}
/** 提交按钮 */
function submitForm() {
  proxy.$refs["userRef"].validate((valid) => {
    if (valid) {
      //单位名称列表数据
      unitNameobj.value.forEach((item) => {
        if (form.value.unitId == item.id) {
          form.value.unitName = item.unitName;
        }
      });
      //线名数据列表
      railwayNameobj.value.forEach((item) => {
        if (form.value.railwayId == item.id) {
          form.value.railwayName = item.railwayName;
        }
      });
      //行别数据列表
      progressTypeobj.value.forEach((item) => {
        if (form.value.lineTypeId == item.id) {
          form.value.lineTypeName = item.progressType;
        }
      });
      // 轨道类型
      tunnelTypeIdList.value.forEach((item) => {
        if (form.value.tunnelTypeId == item.id) {
          form.value.tunnelType = item.propertyName;
        }
      });
      // 洞门进口类型
      portalTypeIdList.value.forEach((item) => {
        if (form.value.portalTypeId == item.id) {
          form.value.portalType = item.propertyName;
        }
      });
      // 隧道边墙类型
      flankWallTypeIdList.value.forEach((item) => {
        if (form.value.flankWallTypeId == item.id) {
          form.value.flankWallType = item.propertyName;
        }
      });
      // 衬砌类型
      liningTypeIdList.value.forEach((item) => {
        if (form.value.liningTypeId == item.id) {
          form.value.liningType = item.propertyName;
        }
      });
      // 路面类型
      roadbedTypeIdList.value.forEach((item) => {
        if (form.value.roadbedTypeId == item.id) {
          form.value.roadbedType = item.propertyName;
        }
      });
      form.value.centreMileage = Math.round(form.value.centreMileage * 1000000) / 1000000;
      if (form.value.startingMileage > form.value.destinationMileage) {
        proxy.$modal.msgError(`起始里程应该小于等于终点里程`);
        return false;
      }
      if (form.value.id) {
        editManTunnelOverview(form.value).then((res) => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addinsertManTunnelOverview(form.value).then((res) => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}
/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}
function selectiontab(row) {
  selecttabList.value = row;
}
// 导出
function handleQuery() {
  const arrid = [];
  for (let i = 0; i < selecttabList.value.length; i++) {
    arrid.push(selecttabList.value[i].id);
  }
  proxy.download1("/facility-manage/overview/exportExcel", arrid, `基本信息${new Date().getTime()}.xlsx`);
}
//重置
function resetQuery() {
  queryParams.value = {
    railwayName: "",
    startingMileage: "",
    destinationMileage: "",
    tunnelCode: "",
  };
  getList();
}
// 查看参数
function parameter(rows) {
  selectManTunnelOverviewById({
    id: rows.id,
  }).then((res) => {
    form.value = res.data;
    getselectManTunnelEditRecordList({
      tunnelId: rows.id,
    }).then((res1) => {
      allBridgeChangeData.value = res1.data;
      title.value = "参数";
      open.value = true;
      parameterShow.value = true;
    });
  });
}
// startingMileage destinationMileage lineTypeId
function updateproperyfun() {
  if (form.value.railwayId != "" && form.value.lineTypeId != "" && form.value.startingMileage != "" && form.value.destinationMileage != "") {
    selectManRailFacilityCurveListapi({
      railwayId: form.value.railwayId,
      progressTypeId: form.value.lineTypeId,
      startMileageNumber: form.value.startingMileage,
      endMileageNumber: form.value.destinationMileage,
    }).then((res) => {
      if (res.code == 200) {
        form.value.curveRadius = "";
        form.value.curveLength = "";
        stationList.value = res.data;
        if (stationList.value.length >= 1) {
          form.value.curveRadius = stationList.value[0].curveRadius;
          form.value.curveLength = stationList.value[0].curveTotalLength;
        }
      }
    });
    selectManRailFacilitySlopeListapi({
      railwayId: form.value.railwayId,
      progressTypeId: form.value.lineTypeId,
      startMileageNumber: form.value.startingMileage,
      endMileageNumber: form.value.destinationMileage,
    }).then((res) => {
      if (res.code == 200) {
        slopeList.value = res.data;
        form.value.slope = "";
        console.log(slopeList.value[0]);
        if (slopeList.value.length >= 1) {
          form.value.slope = slopeList.value[0].slopeGradient;
        }
      }
    });
  }
}
// // 设备
// function equipmentproblem() {
//   equipmentproblemShow.value = true;
// }
// // 业财
// function businessFinance() {
//   businessFinanceShow.value = true;
// }
</script>

<style scoped lang="scss">
.divflex {
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .leftx {
    width: 45%;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #e8e8e8;
    margin-top: 3px;
  }

  .mainz {
    font-weight: 400;
    font-style: normal;
    font-size: 16px;
    line-height: 24px;
  }

  .rightx {
    width: 45%;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #e8e8e8;
    margin-top: 3px;
  }
}

.buttontext {
  .el-button:hover {
    // text-decoration: line-through !important;
  }
}

.el-form--inline .el-form-item.formitemcla {
  margin-right: 5px !important;
}
</style>
